#include "TwitterPlugin.h"
#include "TwitterContext.h"

using namespace TWCore;
namespace Twitter
{
	TwitterPlugin::TwitterPlugin():
		IPlugin("Twitter","WarWithinMe","0.1"){}

	TwitterPlugin::~TwitterPlugin(){}

	void TwitterPlugin::initialize()
	{
		for(int i=0;i<m_contexts.length();++i)
		{
//			m_contexts.at(i)->getSelfInfo();
		}
	}

	bool TwitterPlugin::getConfigWidget( QList<TWCore::IConfigWidget*>& )
	{
		return false;
	}

	IContext* TwitterPlugin::createNewContext()
	{
		TwitterContext* c = new TwitterContext();
		if(!c->setup())
		{
			delete c;
			c = 0;
		}
		m_contexts.append(c);
		return c;
	}

	IContext* TwitterPlugin::createContext(const QByteArray& info)
	{
		TwitterContext* c = 0;
//		if(TwitterContextPrivate::validateSavedInfo(info))
		c = new TwitterContext(info);
		m_contexts.append(c);
		return c;
	}

	void TwitterPlugin::deleteContext(IContext* c)
	{
		m_contexts.removeAll(c);
		delete c;
	}

	void TwitterPlugin::unloadContext(IContext* c)
	{
		m_contexts.removeAll(c);
		delete c;
	}
}

Q_EXPORT_PLUGIN2(Twitter,Twitter::TwitterPlugin);
